﻿using System.Data.Entity.ModelConfiguration;
using Nop.Core.Domain.Stores;

namespace Nop.Data.Mapping.Stores
{
    public partial class StoreMap : EntityTypeConfiguration<Store>
    {
        public StoreMap()
        {
            this.ToTable("Store");
            this.HasKey(m => m.Id);
            this.Property(m => m.Name).IsRequired().HasMaxLength(400);
            this.Property(m => m.Description);
            this.Property(m => m.MetaKeywords).HasMaxLength(400);
            this.Property(m => m.MetaDescription);
            this.Property(m => m.MetaTitle).HasMaxLength(400);
            this.Property(m => m.SeName).HasMaxLength(200);
            this.Property(m => m.PriceRanges).HasMaxLength(400);
            this.Property(m => m.RegionId).IsRequired();

            this.Property(pv => pv.MinOrderSubtotalAmount).HasPrecision(18, 4);
            this.Property(pv => pv.MinOrderTotalAmount).HasPrecision(18, 4);

            this.HasMany(s => s.Branches)
                .WithRequired()
                .HasForeignKey(b => b.StoreId);
        }
    }
}